Plotly Figures
import numpy as np
import scipy.io as sio
import plotly.graph_objects as go
import plotly.tools as tls
from plotly.offline import plot, iplot, init_notebook_mode
from IPython.core.display import display, HTML
init_notebook_mode(connected = True)
config={'showLink': False, 'displayModeBar': False}
os.chdir("/home/jovyan/content/04Plotly")
a = sio.loadmat(file_name = "old.mat", matlab_compatible = True)
G3_old = a['mat']
a = sio.loadmat(file_name = "new.mat", matlab_compatible = True)
G3 = a['mat']
x = np.arange(29)
fig = go.Figure()
fig.add_trace(go.Scatter(x=x, y=G3_old[0],
mode='lines',
))
fig.add_trace(go.Scatter(x=x, y=G3_old[1],
mode='lines',
))
fig.add_trace(go.Scatter(x=x, y=G3_old[2],
mode='lines',
))
#Binder and ThebeLab
plot(fig, filename = 'fig.html', config = config)
#ThebeLab
display(HTML('fig.html'))
#Binder
#plot(fig,config=config)
fig2 = go.Figure()
fig2.add_trace(go.Scatter(x=x, y=G3[0],
mode='lines',
))
fig2.add_trace(go.Scatter(x=x, y=G3[1],
mode='lines',
))
fig2.add_trace(go.Scatter(x=x, y=G3[2],
mode='lines',
))
#Binder and ThebeLab
plot(fig2, filename = 'fig2.html', config = config)
#ThebeLab
display(HTML('fig2.html'))
#Binder
#plot(fig2,config=config)
fig3 = go.Figure()
fig3.add_trace(go.Scatter(x=x, y=G3_old[0],
mode='lines',
name = 'Line 1 before'
))
fig3.add_trace(go.Scatter(x=x, y=G3[0],
mode='lines',
name = 'Line 1 after'
))
fig3.add_trace(go.Scatter(x=x, y=G3_old[1],
mode='lines',
name = 'Line 2 before'
))
fig3.add_trace(go.Scatter(x=x, y=G3[1],
mode='lines',
name = 'Line 2 after'
))
fig3.add_trace(go.Scatter(x=x, y=G3_old[2],
mode='lines',
name = 'Line 2 before'
))
fig3.add_trace(go.Scatter(x=x, y=G3[2],
mode='lines',
name = 'Line 3 after'
))
fig3.update_layout(
updatemenus=[
dict(
active=0,
buttons=list([
dict(label="Show All",
method="update",
args=[{"visible": [True, True, True, True, True, True]},
{"title": "Before and After Comparation"}]),
dict(label="Line 1",
method="update",
args=[{"visible": [True, True, False, False, False, False]},
{"title": "Line 1 comparation"}]),
dict(label="Line 2",
method="update",
args=[{"visible": [False, False, True, True, False, False]},
{"title": "Line 2 comparation"
}]),
dict(label="Line 3",
method="update",
args=[{"visible": [False, False,False,False, True, True]},
{"title": "Line 3 comparation"}]),
]),
)
])
fig3.update_layout(title_text="Before and After Comparation")
#Binder and ThebeLab
plot(fig3, filename = 'fig3.html', config = config)
#ThebeLab
display(HTML('fig3.html'))
#Binder
# iplot(fig3,config=config)